package com.winchain.chainbill.serfee.rx;

import com.shell.framework.rx.OnErrorNotImplementedSubscriber;
import com.winchain.chainbill.ChainBillUtil;
import com.winchain.chainbill.bill.base.po.CbDct;
import com.winchain.chainbill.bill.base.po.CbRec;
import com.winchain.chainbill.bill.biz.Bill;
import com.winchain.chainbill.bill.biz.BillEvent;
import com.winchain.chainbill.serfee.service.impl.ServiceFeeAttService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class BillDctReAprvSignDebitCertSubscriber extends OnErrorNotImplementedSubscriber<BillEvent<CbDct>> {
	@Autowired
	private ServiceFeeAttService serviceFeeAttService;

	public void onApplicationEvent(BillEvent<CbDct> t) {
		CbDct dct = (CbDct) t.getBill().getSource();
		this.serviceFeeAttService.genDebitCert(dct.getDctId(), "0");
		if (ChainBillUtil.onCfca()) {
			CbRec rec = t.getBill().getRec();
			this.serviceFeeAttService.signDebitCert(rec.getBillId(), dct.getFinId(), dct.getFinNm(), dct.getDctId(),
					"0");
		}
	}
}
